<template>
  <tr class="grid-row-tr">
    <td class="grid-check-box"><input :name="formGroup" @click="onclick" v-bind:type="checkType"/></td>
    <slot></slot>
  </tr>
</template>

<script>

export default {
  name: "GridRowComponent",
  data(){
    return{
      checkType:"radio",
      selectFlag:0
    }
  },
  props:{
    type:String,// head-表头、content-数据体
    showData:Object,
    formGroup:String
  },
  methods:{
    onclick:function () {
      if (0 === this.selectFlag) {
        this.$parent.$emit("recordSelect", this.showData);
        this.selectFlag=1;
      } else {
        this.$parent.$emit("recordUnSelect", this.showData);
        this.selectFlag=0;
      }
    }
  },
  mounted() {
    let selectModuel = this.$parent.$props["selectModuel"];
    if("single"===selectModuel){
      this.checkType="radio";
    }else{
      this.checkType="checkbox";
    }
  }
}
</script>

<style scoped>
.grid-row-tr{
  border-bottom: 1px solid #cccccc;
  line-height: 35px;
}
.grid-check-box{
  width: 15px;
  border-right: 1px solid #cccccc;
}
.grid-row-tr:hover{
  background: #eee;
}
</style>